<template>
  <div class="address">
    <el-select v-model="address" placeholder="请选择" ref="selectReport">
      <el-option :value="address" class="option" style="height: auto" >
        <el-tree :data="deptOptions" :props="defaultProps"  @node-click="handleNodeClick"></el-tree>
      </el-option>
    </el-select>
  </div>
</template>

<script>
  import {treeselect,cunfangweizhi } from "@/api/system/dept";
    export default {
      name: "address.vue",
      props:[
        'numdata',
        'type',
      ],
      components:{
        //Treeselect,
      },
      data(){
          return{
            num:-1,
            address:undefined,
            defaultProps: {
              children: "children",
              label: "label"
            },
            deptOptions:[],
          }
      },
      created() {
        this.num = this.numdata
        this.getTreeselect()
      },
      methods: {
        /** 查询类别下拉树结构 */
        getTreeselect() {
          cunfangweizhi().then(response => {
            this.deptOptions = response.rows;
            //console.log(response.data);
          });
        },
        handleNodeClick(data) {
          debugger
          if(this.type=='dianrididian'){
            var obj=''
            obj = data
            obj.num =  this.num
            this.address=data.label
            this.$refs.selectReport.blur()
            this.$emit('addSelectChangedd', obj)
            return
          }else {
            this.address=data.label
            this.$refs.selectReport.blur()
            this.$emit('addSelectChange', data)
          }

        }
      }
    }
</script>

<style  lang="scss">
  .address{
    .option{
      height:auto;
    }

  }
</style>
